<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            overflow: hidden;
        }

        iframe {
            width: 100%;
            height: 100vh;
        }
    </style>
</head>
<body>
<button id="btn">切换</button>
<iframe id="iframe" src="127.0.0.1.158:8888/#/preview/1?showSceneList=0&showSceneListCtrl=0&showMusicCtrl=0&showRoamCtrl=0&showMarksCtrl=0&showFullScreenCtrl=0" frameborder="0"></iframe>
</body>
</html>

<script>
    // 监听iframe加载完成事件
    document.querySelector('iframe').onload = function () {
        console.log('iframe加载完成');

    }

    // 监听iframe发送的消息
    window.addEventListener('message', function (event) {
        console.log(event)
    }, false);


    document.getElementById('btn').addEventListener('click', function () {
        var iframe = document.querySelector('#iframe');

        iframe.src = '127.0.0.1.158:8888/#/preview/2';


    })





</script>
